home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / X11 / Xmu / EditresP.h < prev    next >
C/C++ Source or Header  |  2006-04-12  |  10KB  |  410 lines

  1. /* $Xorg: EditresP.h,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
  2.  
  3. /*
  4.  
  5. Copyright 1989, 1998  The Open Group
  6.  
  7. Permission to use, copy, modify, distribute, and sell this software and its
  8. documentation for any purpose is hereby granted without fee, provided that
  9. the above copyright notice appear in all copies and that both that
  10. copyright notice and this permission notice appear in supporting
  11. documentation.
  12.  
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15.  
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  19. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  20. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22.  
  23. Except as contained in this notice, the name of The Open Group shall not be
  24. used in advertising or otherwise to promote the sale, use or other dealings
  25. in this Software without prior written authorization from The Open Group.
  26.  
  27. */
  28. /* $XFree86: xc/lib/Xmu/EditresP.h,v 1.5 2001/01/17 19:42:55 dawes Exp $ */
  29.  
  30. /*
  31.  * Author:  Chris D. Peterson, MIT X Consortium
  32.  */
  33.  
  34. /************************************************************
  35.  
  36.         The Editres Protocol
  37.  
  38.  
  39.   The Client message sent to the application is:
  40.  
  41.   ATOM = "ResEditor"         --- RES_EDITOR_NAME
  42.  
  43.   FORMAT = 32                   --- RES_EDIT_SEND_EVENT_FORMAT
  44.  
  45.   l[0] = timestamp
  46.   l[1] = command atom name
  47.   l[2] = ident of command
  48.   l[3] = protocol version number to use
  49.  
  50.  
  51.  
  52.   The binary protocol has the following format:
  53.  
  54.     Card8:        8-bit unsingned integer
  55.     Card16:        16-bit unsingned integer
  56.     Card32:        32-bit unsingned integer
  57.     Int16:        16-bit signed integer
  58.     Window:        32-bit value
  59.     Widget:        32-bit value
  60.     String8:        ListOfCard8
  61.     
  62.     [a][b][c] represent an exclusive list of choices.
  63.  
  64.     All widgets are passed as a list of widgets, containing the 
  65.     full instance heirarch of this widget.  The hierarchy is ordered
  66.     from parent to child.  Thus the first element of each list is
  67.     the root of the widget tree (this makes verifying that the widget
  68.     still exists, MUCH faster).
  69.  
  70.     ListOfFoo comprises a list of things in the following format:
  71.     
  72.     number:            Card16
  73.     <number> things:    ????
  74.     
  75.   This is a synchronous protocol, every request MUST be followed by a
  76.   reply.  
  77.  
  78.   Request:
  79.  
  80.     Serial Number:    Card8
  81.     Op Code:    Card8 -    { SendWidgetTree = 0,
  82.                   SetValues = 1,
  83.                   GetResources = 2,
  84.                   GetGeometry = 3,
  85.                   FindChild = 4,
  86.                   GetValues = 5 }
  87.     Length:        Card32
  88.     Data:        
  89.  
  90.    Reply:
  91.  
  92.     Serial Number:    Card8
  93.     Type:        Card8 - { Formatted = 0,
  94.                               Unformatted = 1,
  95.                   ProtocolMismatch = 2
  96.                 }
  97.     Length:        Card32
  98.  
  99.  
  100.    Byte Order:
  101.  
  102.     All Fields are MSB -> LSB
  103.  
  104.     Data:
  105.  
  106.         Formatted:
  107.  
  108.             The data contains the reply information for the request as
  109.         specified below if the reply type is "Formatted".  The return
  110.         values for the other reply types are shown below.
  111.  
  112.         Unformatted:
  113.  
  114.         Message:    String8
  115.  
  116.     ProtocolMismatch:
  117.  
  118.         RequestedVersion:       Card8
  119.  
  120. ------------------------------------------------------------
  121.  
  122.    SendWidgetTree:
  123.  
  124.     --->
  125.  
  126.     Number of Entries:    Card16
  127.     Entry:
  128.         widget:        ListOfWidgets
  129.         name:        String8
  130.         class:        String8
  131.         window:        Card32
  132.              toolkit:        String8
  133.  
  134.     Send Widget Tree returns the toolkit type, and a fuly specified list
  135.         of widgets for each widget in the tree.  This is enough information
  136.         to completely reconstruct the entire widget heirarchy.
  137.  
  138.     The window return value contains the Xid of the window currently 
  139.     used by this widget.  If the widget is unrealized then 0 is returned,
  140.     and if widget is a non-windowed object a value of 2 is returned.
  141.  
  142.    SetValues:
  143.  
  144.     name:    String8
  145.     type:    String8
  146.     value:  String8
  147.     Number of Entries:    Card16
  148.     Entry:
  149.         widget:        ListOfWidgets
  150.  
  151.     --->
  152.  
  153.     Number of Entries:    Card16
  154.     Entry:
  155.         widget:        ListOfWidgets
  156.         message:    String8
  157.  
  158.     SetValues will allow the same resource to be set on a number of 
  159.     widgets.  This function will return an error message if the SetValues
  160.     request caused an Xt error.
  161.     
  162.   GetValues:
  163.  
  164.         names:                ListOfString8       
  165.         widget:               Widget
  166.  
  167.         --->
  168.     novalues:             ListOfCard16
  169.     values:               ListOfString8
  170.                    
  171.         GetValues will allow a number of resource values to be read 
  172.         on a particular widget.  The request specifies the names of
  173.     the resources wanted and the widget id these resources are
  174.     from.  The reply returns a list of indices from the requests
  175.     name list of resources for which a value can not be returned.
  176.     It also returns a list of returned values, in the order of the
  177.         requests names list, skipping those indices present in novalues.
  178.  
  179.    GetResources:
  180.  
  181.     Number of Entries:    Card16
  182.     Entry
  183.         widget:        ListOfWidgets:
  184.  
  185.     ---->
  186.  
  187.     Number of Entries:    Card16
  188.     Entry
  189.         Widget:            ListOfWidgets:
  190.         Error:            Bool
  191.  
  192.         [ Message:        String 8 ]
  193.         [ Number of Resources:    Card16
  194.         Resource:
  195.             Kind:    {normal, constraint}
  196.             Name:    String8
  197.             Class:    String8    
  198.             Type:    String8 ]
  199.  
  200.     GetResource retrieves the kind, name, class and type for every 
  201.     widget passed to it.  If an error occured with the resource fetch
  202.     Error will be set to True for the given widget and a message
  203.     is returned rather than the resource info.
  204.  
  205.   GetGeometry:
  206.  
  207.     Number of Entries:    Card16
  208.     Entry
  209.         Widget:        ListOfWidgets:
  210.  
  211.     ---->
  212.  
  213.     Number of Entries:    Card16
  214.     Entry
  215.         Widget:            ListOfWidgets:
  216.         Error:            Bool
  217.  
  218.         [ message:        String 8 ]
  219.         [ mapped:       Boolean
  220.           X:         Int16
  221.           Y:          Int16
  222.           Width:     Card16
  223.                 Height:    Card16
  224.           BorderWidth:    Card16 ]
  225.  
  226.     GetGeometry retreives the mapping state, x, y, width, height
  227.     and border width for each widget specified.  If an error occured 
  228.     with the geometry fetch "Error" will be set to True for the given 
  229.     widget and a message is returned rather than the geometry info.  
  230.     X an Y corrospond to the root coordinates of the upper left corner
  231.     of the widget (outside the window border).
  232.     
  233.   FindChild:
  234.  
  235.     Widget:        ListOfWidgets
  236.     X:        Int16
  237.     Y:        Int16
  238.     
  239.     --->
  240.  
  241.     Widget:        ListOfWidgets
  242.  
  243.     Find Child returns a descendent of the widget specified that 
  244.     is at the root coordinates specified.
  245.  
  246.     NOTE:
  247.  
  248.     The returned widget is undefined if the point is contained in
  249.     two or more mapped widgets, or in two overlapping Rect objs.
  250.  
  251.   GetValues:
  252.  
  253.         names:                ListOfString8       
  254.         widget:               Widget
  255.  
  256.         --->
  257.     
  258.     values:               ListOfString8
  259.  
  260.         GetValues will allow a number of resource values to be read 
  261.         on a particular widget.  Currently only InterViews 3.0.1 Styles 
  262.     and their attributes are supported.  In addition, the current
  263.     user interface  only supports the return of 1 resource.  The ability
  264.     to specify and return multiple resources is defined for future editres
  265.     interfaces where some or all of a widgets resource values are returned
  266.     and displayed at once. 
  267.  
  268.  
  269. ************************************************************/
  270.  
  271. #include <X11/Intrinsic.h>
  272. #include <X11/Xfuncproto.h>
  273.  
  274. #define XER_NBBY 8        /* number of bits in a byte */
  275. #define BYTE_MASK 255
  276.  
  277. #define HEADER_SIZE 6
  278.  
  279. #define EDITRES_IS_OBJECT 2
  280. #define EDITRES_IS_UNREALIZED 0
  281.  
  282. /*
  283.  * Format for atoms
  284.  */
  285. #define EDITRES_FORMAT             8
  286. #define EDITRES_SEND_EVENT_FORMAT 32
  287.  
  288. /*
  289.  * Atoms
  290.  */
  291. #define EDITRES_NAME         "Editres"
  292. #define EDITRES_COMMAND_ATOM "EditresCommand"
  293. #define EDITRES_COMM_ATOM    "EditresComm"
  294. #define EDITRES_CLIENT_VALUE "EditresClientVal"
  295. #define EDITRES_PROTOCOL_ATOM "EditresProtocol"
  296.  
  297. typedef enum {
  298.   SendWidgetTree = 0,
  299.            SetValues      = 1,
  300.            GetResources   = 2,
  301.            GetGeometry    = 3, 
  302.            FindChild      = 4,
  303.            GetValues      = 5
  304. } EditresCommand;
  305.  
  306. typedef enum {
  307.   NormalResource     = 0,
  308.   ConstraintResource = 1
  309. } ResourceType;
  310.  
  311. /*
  312.  * The type of a resource identifier
  313.  */
  314. typedef unsigned char ResIdent;
  315.  
  316. typedef enum {
  317.   PartialSuccess   = 0,
  318.   Failure       = 1,
  319.   ProtocolMismatch = 2
  320. } EditResError;
  321.  
  322. typedef struct _WidgetInfo {
  323.     unsigned short num_widgets;
  324.   unsigned long *ids;
  325.     Widget real_widget;
  326. } WidgetInfo;
  327.  
  328. typedef struct _ProtocolStream {
  329.     unsigned long size, alloc;
  330.     unsigned char *real_top, *top, *current;
  331. } ProtocolStream;
  332.  
  333. /************************************************************
  334.  * Function definitions for reading and writing protocol requests
  335.  ************************************************************/
  336. _XFUNCPROTOBEGIN
  337.  
  338. void _XEditResPutString8
  339. (
  340.  ProtocolStream        *stream,
  341.  char            *str
  342.  );
  343.  
  344. void _XEditResPut8
  345. (
  346.  ProtocolStream        *stream,
  347.  unsigned int        value
  348.  );
  349.  
  350. void _XEditResPut16
  351. (
  352.  ProtocolStream        *stream,
  353.  unsigned int        value
  354.  );
  355.  
  356. void _XEditResPut32
  357. (
  358.  ProtocolStream        *stream,
  359.  unsigned long        value
  360.  );
  361.  
  362. void _XEditResPutWidgetInfo
  363. (
  364.  ProtocolStream        *stream,
  365.  WidgetInfo        *info
  366.  );
  367.  
  368. void _XEditResResetStream
  369. (
  370.  ProtocolStream        *stream
  371.  );
  372.  
  373. Bool _XEditResGet8
  374. (
  375.  ProtocolStream        *stream,
  376.  unsigned char        *value
  377.  );
  378.  
  379. Bool _XEditResGet16
  380. (
  381.  ProtocolStream        *stream,
  382.  unsigned short        *value
  383.  );
  384.  
  385. Bool _XEditResGetSigned16
  386. (
  387.  ProtocolStream        *stream,
  388.  short            *value
  389.  );
  390.  
  391. Bool _XEditResGet32
  392. (
  393.  ProtocolStream        *stream,
  394.  unsigned long        *value
  395.  );
  396.  
  397. Bool _XEditResGetString8
  398. (
  399.  ProtocolStream        *stream,
  400.  char            **str
  401.  );
  402.  
  403. Bool _XEditResGetWidgetInfo
  404. (
  405.  ProtocolStream        *stream,
  406.  WidgetInfo        *info
  407.  );
  408.  
  409. _XFUNCPROTOEND
  410.